package com.px.user.entity;

import com.fasterxml.jackson.annotation.JsonFormat;
import com.px.user.model.ActionModel;
import io.swagger.annotations.ApiModel;
import io.swagger.annotations.ApiModelProperty;
import lombok.AllArgsConstructor;
import lombok.Builder;
import lombok.Data;
import lombok.NoArgsConstructor;
import org.hibernate.annotations.Generated;
import org.hibernate.annotations.GenerationTime;

import javax.persistence.*;
import javax.validation.constraints.NotBlank;
import javax.validation.constraints.NotNull;
import javax.validation.constraints.Null;
import java.sql.Timestamp;


@Data
@Builder
@AllArgsConstructor
@NoArgsConstructor
@Entity(name = "room_marquee")
@ApiModel(value = "房间跑马灯对象", description = "房间跑马灯字段")
@org.hibernate.annotations.Table(appliesTo = "room_marquee", comment = "房间跑马灯表")
public class RoomMarquee {

    @Id
    @NotNull(groups = {ActionModel.Update.class})
    @ApiModelProperty(value = "主键", hidden = true)
    @GeneratedValue(strategy = GenerationType.IDENTITY)
    @Null(groups = {ActionModel.Insert.class}, message = "删除id字段")
    @Column(unique = true, nullable = false, columnDefinition = "int comment '主键'")
    private Integer id;

    @Column(columnDefinition = "bigint comment '创建人ID'")
    @ApiModelProperty(value = "创建者ID", example = "1", hidden = true)
    private Long creatorId;

    @NotNull(groups = {ActionModel.Insert.class})
    @ApiModelProperty(value = "房间ID", example = "3")
    @Column(columnDefinition = "bigint comment '房间ID'")
    private Long roomId;

    @Column(columnDefinition = "varchar(32) comment '角色'")
    @ApiModelProperty(value = "角色", example = "TEACHER", hidden = true)
    private String role;

    @NotBlank(groups = {ActionModel.Insert.class})
    @ApiModelProperty(value = "跑马灯", example = "欢迎来玩")
    @Column(columnDefinition = "varchar(1024) comment '跑马灯'")
    private String marquee;

    @NotNull(groups = {ActionModel.Insert.class})
    @ApiModelProperty(value = "次数", example = "10")
    @Column(columnDefinition = "int comment '次数'")
    private Integer times;

    @Generated(GenerationTime.INSERT)
    @ApiModelProperty(value = "创建时间", hidden = true)
    @JsonFormat(shape = JsonFormat.Shape.STRING, pattern = "yyyy-MM-dd HH:mm:ss", timezone = "GMT+8")
    @Column(columnDefinition = "TIMESTAMP DEFAULT CURRENT_TIMESTAMP comment '创建时间'", insertable = false, updatable = false)
    private Timestamp createTime;
}
